package com.yygo.dao.hibernate;

import com.yygo.Constants;
import com.yygo.dao.CommissionTransferDao;
import com.yygo.model.CommissionTransferRecord;
import com.yygo.model.enums.CommissionStatus;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by tiansha on 2015/11/29.
 */
@Repository("commissionTransferDao")
public class CommissionTransferDaoHibernate extends GenericDaoHibernate<CommissionTransferRecord, Long> implements CommissionTransferDao {

    public CommissionTransferDaoHibernate() {
        super(CommissionTransferRecord.class);
    }

    @Override
    public List<CommissionTransferRecord> getPendingCityCommissions() {
        Criteria criteria = getSession().createCriteria(CommissionTransferRecord.class).add(Restrictions.eq("cityCommissionStatus", CommissionStatus.pending));
        return criteria.list();
    }

    @Override
    public List<CommissionTransferRecord> getPendingCountyCommissions() {
        Criteria criteria = getSession().createCriteria(CommissionTransferRecord.class).add(Restrictions.eq("countyCommissionStatus", CommissionStatus.pending));
        return criteria.list();
    }

    @Override
    public List<CommissionTransferRecord> getPendingDealerCommissions() {
        Criteria criteria = getSession().createCriteria(CommissionTransferRecord.class).add(Restrictions.eq("dealerCommissionStatus", CommissionStatus.pending));
        return criteria.list();
    }

}
